
<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="/static/css/backTemplate.css"> 
   	<!--[if lt IE 9]>
    　 <script src="https://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
       <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.js"></script>
    <![endif]-->
    <style type="text/css">
    	body {font-family: '微软雅黑'; }
    	span {color:red;  }
    </style>
</head>
<body>
	<div class="admin-main-content" id="admin-main-content">
		<form class="form-horizontal" id="main-form">
			<!-- 原登陆密码 -->
			<div class="form-group">
				<label for="old_pwd" class="col-sm-2 control-label">原登陆密码<span>*</span>：</label>
			    <div class="col-sm-3">
			      	<input type="text" class="form-control" id="old_pwd" name="old_pwd" required value="">
			    </div> 
			</div>
 
			<!-- 新登陆密码 -->
			<div class="form-group">
				<label for="new_pwd" class="col-sm-2 control-label">新登陆密码<span>*</span>：</label>
			    <div class="col-sm-3">
			      	<input type="password" class="form-control" id="new_pwd" name="new_pwd" required value="">
			    </div> 
			</div>

			<!-- 重复新密码 -->
			<div class="form-group">
				<label for="sure_pwd" class="col-sm-2 control-label">确认新密码<span>*</span>：</label>
			    <div class="col-sm-3">
			      	<input type="password" class="form-control" id="sure_pwd" name="sure_pwd" required value="">
			    </div> 
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-3 tb_item">
					<button type="button" class="btn btn-info">保存</button>
				</div>
			</div>
		</form>
	</div>

	<input type="hidden" id="base_url" value="<?=base_url() ?>">
	<script type="text/javascript" src="/static/lib/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" src="/static/lib/jquery.validate.js"></script>
	<script type="text/javascript">
		$('#main-form').validate();

		$(".tb_item").click(function(){
			var old_pwd = $.trim($("#old_pwd").val());
			var new_pwd = $.trim($("#new_pwd").val());
			var sure_pwd = $.trim($("#sure_pwd").val());

			if((!old_pwd) || (!new_pwd) || (!sure_pwd))
			{
				alert('原始密码或新密码或确认密码不能为空');
				return;
			}

			if(new_pwd != sure_pwd)
			{
				alert('新密码和确认密码不一致');
				return;
			}
			$.ajax({
				url: '<?=base_url().'Admin/Index/editPass' ?>',
				type: 'POST',
				dataType: 'json',
				data: {old_pwd: old_pwd,new_pwd: new_pwd,sure_pwd: sure_pwd},
				success: function(json){
					if ((typeof json) == "string") {
						json = JSON.parse(json);
					}

					alert(json.msg);
					if(json.code == 0)
					{
						return;
					}else{
						window.top.location.href = "<?=base_url().'Admin/Login/login' ?>";
					}
					
				},
				error: function(){
					alert('出错了');
				}
			});

		});
	</script>
</body>
</html>